function sjx(a1,a2,a3,n1)
triangle1=[a1,a2,a3,a1];
b1=(a1+a2)/2;b2=(a1+a3)/2;b3=(a2+a3)/2;
triangle2=[b1,b2,b3,b1];
n2=n1-1;
if n2>0
    sjx(a1,b1,b2,n2);
    sjx(b1,a2,b3,n2);
    sjx(b2,b3,a3,n2);
    subplot(2,3,n2);
    fill(real(triangle1),imag(triangle1),'g');
    hold on
    fill(real(triangle2),imag(triangle2),'w');
end